//
// Created by Administrator on 2022/1/2.
//

#ifndef CPP_LEARNING_BIN_TREE_TEST_HPP
#define CPP_LEARNING_BIN_TREE_TEST_HPP

#include "../src/bin_tree.hpp"

#include <iostream>
using namespace std;

namespace BIN_TREE_TEST{

    template <typename T>
    struct Visit_TREE{
        void operator() ( T& e){
            cout<<e<<" ";
        }
    };



/**
 * 对这样的树进行测试
 *                                                  8
 *                        4                                                        11
 *
 *           2                        6                              9                         12
 *     1           3            5            7                                10
 */


    void bin_tree_test(){
        BinTree<int >* tree = new BinTree<int>;

        BinNode<int>* node;
        BinNode<int>* node8 = tree->insertAsRoot(8);
        BinNode<int>* node4 = tree->insertAsLC(node8,4);
        BinNode<int>* node11 = tree->insertAsRC(node8,11);

        BinNode<int>* node9 = tree->insertAsLC(node11,9);
        BinNode<int>* node10 = tree->insertAsRC(node9,10);

        Visit_TREE<int> visit;
        tree->travPost(visit);
        cout<<endl;
        tree->travIn(visit);
        cout<<endl;



    }
}

#endif //CPP_LEARNING_BIN_NODE_TEST_HPP
